#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/5
# @Author  : LiJun
# @Email   : lijun@tianyancha.com
# @Version : 1.0.0
import allure

from common.appium_base_method import BasePage
from appium_0704.page.personal_info_page import PersonalInfo

class AddressBook(BasePage):

    @allure.step("点击「成员」")
    def click_member(self):
        # 点击成员，进入人员详情页
        members = self.finds(*self.by_maps(self.element["PersonalId"]))[3:-1]
        from selenium.common.exceptions import NoSuchElementException
        try:
            members[0].find_element(*self.by_maps(self.element["PersonalSign"]))
            members[1].click()
        except NoSuchElementException:
            members[0].click()

        return PersonalInfo(self.driver, element=self.element)

    @allure.step("获取「通讯录」底部成员人数文案")
    def get_members_text(self):
        text = self.swipt_find(*self.by_maps(self.element["NumberOfPeople"])).text

        return text

